﻿/*
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Reflection;

namespace ConsoleApplication
{
    class YahooNZBData
    {
        public String title;
        public string imdbID;
        public string imdbLink
        {
            get { return string.Format("http://www.imdb.com/title/tt{0}", imdbID); }
        }
        public string movieDbLink
        {
            get { return string.Format("http://www.dropio.com/blah/blah/", imdbID); }
        }
        public string rating;
        public string genre;
        public string feedtitle;
        public string plot;
        public string year;
        public string description;
        public string resolution;

        private static FieldInfo[] myFieldInfo;

        static YahooNZBData()
        {
            myFieldInfo = typeof(YahooNZBData).GetFields();
        }

        public YahooNZBData(JObject jsonObject)
        {
            try 
            {
                foreach (FieldInfo fi in myFieldInfo)
                {
                    JToken token = jsonObject[fi.Name];

                    if (token == null || token.Type == JTokenType.Null)
                        continue;

                    if (fi.FieldType == typeof(string))
                        fi.SetValue(this, (string)token);
                    else if (fi.FieldType == typeof(int))
                        fi.SetValue(this, (int)token);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("couldn't make the nzb...");
                throw new ArgumentException("couldn't make it happen... its flapping away!", e);
            }
        }
    }

    class YahooPipesReader
    {
        public static Dictionary<string, YahooNZBData> ReadJSONPipe(string url)
        {
            string jsonData = null;
            try
            {
                WebClient wb = new WebClient();
                byte[] jsonRawData = wb.DownloadData(url);
                jsonData = ASCIIEncoding.ASCII.GetString(jsonRawData);
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot request the pipe...");
                Console.WriteLine(e.ToString());
                return null;
            }

            FAIL_IF(string.IsNullOrEmpty(jsonData), "request succeded... but decode failed");

            JObject json = null;

            try
            {
                json = JObject.Parse(jsonData);
            }
            catch (Exception e)
            {
                Console.WriteLine("failed to parse yahoo json data");
                Console.WriteLine(e.ToString());
            }

            FAIL_IF(json == null, "failed to parse data");

            Dictionary<string, YahooNZBData> data = new Dictionary<string, YahooNZBData>();

            int count;
            JObject jData;
            FAIL_IF(!int.TryParse(json["count"].ToString(), out count), "couldn't parse count");
            FAIL_IF((jData = (JObject)json["value"]) == null, "failed read");

            JContainer itemArray = (JContainer)jData["items"];

            JToken curItem = itemArray.First.Next;
            while (curItem != null)
            {
                JObject thisObj = curItem as JObject;
                if (thisObj != null)
                {
                    string title = (string)thisObj["title"];
                    title = title.Replace(".", " ").Trim();

                    if (!data.ContainsKey(title))
                    {
                        data.Add(title, new YahooNZBData(thisObj));
                    }
                }
                curItem = curItem.Next;
            }

            return data;
        }

        static void FAIL_IF(bool b, string s)
        {
            if (b)
            {
                Console.WriteLine(s);
                throw new Exception("failed");
            }
        }
    }
}
*/